﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Mirkuz.UI;
namespace Mirkuz.TrailCompanion
{
    public partial class fSettings : Mirkuz.UI.TForm
    {
        System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(fSettings));

        public fSettings()
        {
            InitializeComponent();            
        }

        private void mnuOK_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.OK;
            this.Close();
        }

        private void mnuCancel_Click(object sender, EventArgs e)
        {
            this.DialogResult = DialogResult.Cancel;
            this.Close();
        }

        private void fSettings_Load(object sender, EventArgs e)
        {
            //combo autosave
            tcmbAutosave.ComboItems.Add(new TComboItem("Yes", Properties.Resources.combobackground_enabled,"yes"));
            tcmbAutosave.ComboItems.Add(new TComboItem("No", Properties.Resources.combobackground_disabled,"no"));
            if (fMain.settingDataSet1.Settings[0].AutosaveEnabled)
                tcmbAutosave.SelectedItem = tcmbAutosave.ComboItems[0];
            else
                tcmbAutosave.SelectedItem = tcmbAutosave.ComboItems[1];       

            //comobo unità
            tcmbMetricImperial.ComboItems.Add(new TComboItem("Metric", Properties.Resources.combobackground, "0"));
            tcmbMetricImperial.ComboItems.Add(new TComboItem("Imperial", Properties.Resources.combobackground, "1"));
            tcmbMetricImperial.SelectedItem = tcmbMetricImperial.ComboItems[fMain.settingDataSet1.Settings[0].Units.ToString()];
            
            //combo gps
            tcmbGPSKind.ComboItems.Add(new TComboItem("Automatic", Properties.Resources.combobackground_enabled, "GPSID"));
            string[] sports = System.IO.Ports.SerialPort.GetPortNames();
            foreach (string s in sports)
                tcmbGPSKind.ComboItems.Add(new TComboItem(s, Properties.Resources.combobackground, s));
            if (!sports.Contains(fMain.settingDataSet1.Settings[0].GPSKind))
                tcmbGPSKind.SelectedItem = tcmbGPSKind.ComboItems[0];
            else
                tcmbGPSKind.SelectedItem = tcmbGPSKind.ComboItems[fMain.settingDataSet1.Settings[0].GPSKind];
            
            //combo polling
            tcmbPolling.ComboItems.Add(new TComboItem("10 seconds", Properties.Resources.combobackground_enabled, "10"));
            tcmbPolling.ComboItems.Add(new TComboItem("30 seconds", Properties.Resources.combobackground_enabled, "30"));
            tcmbPolling.ComboItems.Add(new TComboItem("1 minute", Properties.Resources.combobackground_enabled, "60"));
            tcmbPolling.ComboItems.Add(new TComboItem("2 minutes", Properties.Resources.combobackground_enabled, "120"));
            tcmbPolling.ComboItems.Add(new TComboItem("5 minutes", Properties.Resources.combobackground_enabled, "300"));
            tcmbPolling.SelectedItem = tcmbPolling.ComboItems[fMain.settingDataSet1.Settings[0].GPSPolling.ToString()];
                 
        }

    }
}